<?php
class Mozg_Env
{
    /**
		список протоколов и их окружений
     */
    static private $_envNames = array();
    
    static private $_isEnvLoaded = false;

	private function __construct (){}
    
    static private function LoadEnv ()
    {
        if (self::$_isEnvLoaded) return $this;
        
        self::$_isEnvLoaded = true;
        self::$_envNames = include (_APP_PATH . 'env.php');
    }
    
    static public function IsRightProt ($protName)
    {
        self::LoadEnv();
        return isset(self::$_envNames[strtolower($protName)]);
    }
    
    static public function IsRightEnv ($protName, $envName)
    {
        self::LoadEnv();
        return in_array(strtolower($envName), self::$_envNames[strtolower($protName)]);
    }
    
    static public function GetProtList ()
    {
        self::LoadEnv();
        return array_keys(self::$_envNames);
    }
    
    static public function GetEnvList ($protName)
    {
        if (! self::IsRightProt($protName)) throw new Mozg_Exception_System(Mozg_Lang::_('PROTOCOL_%_NOT_FOUND', $protName));
        return self::$_envNames[strtolower($protName)];
    }
}